<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta content="phalconplus API doc" name="description">
    <title>
                    phalconplus API Documentation
            </title>
    <link rel="stylesheet" type="text/css" href="../../../asset/static/prettify.css" />

<script src="../../../asset/static/prettify.js"></script>
<script src="../../../asset/api_definition.js"></script>


                        <link rel="stylesheet" type="text/css" href="../../../asset/static/prettify.css" />
                    <link rel="stylesheet" type="text/css" href="../../../asset/static/zephir-theme.css" />
            
    

                        <script src="../../../asset/static/prettify.js"></script>
                                    <script src="../../../asset/api_definition.js"></script>
                    <script src="../../../asset/static/jquery.min.js"></script>
                    <script src="../../../asset/static/zephir-doc.js"></script>
                <script type="application/javascript">let ZepCurrentPath = '../../../'</script>
    </head>
 <body onload="prettyPrint()">
        <div id="top-bar">
            <div id="top-left">
                                    phalconplus Documentation <span class="version">v1.1.0</span>
                            </div>
            <div id="top-right">
            </div>
        </div>
        <div id="body">
            <div id="body-left">
                <div class="header-search">
                    <input class="search-box" placeholder="Search for a class or namespace " type="text" />
                    <div id="menu-wrapper">
                    </div>
                </div>
            </div>
            <div id="body-right">
                <div class="content">
                    
<div class="breadcrumb">
    
    <ul>
        
        <li><a href="../../../index.html">Home</a></li>
        
                <li><a href="../../../classes.html">Classes</a></li>
                <li><a href="../../../class/PhalconPlus/Rpc/Yar.html">PhalconPlus\Rpc\Yar</a></li>
                <li><a >Source</a></li>
                
    </ul>
    
</div>
<div class="class-header source clearfix">
    
    <div class="access-buttons">
        <a class="zep-button" href="../../../class/PhalconPlus/Rpc/Yar.html">Class</a>

            </div>
    
    <div class="class-full-name">
        <span class="class-type">Class</span>
        
                <span class="namespace-piece">
            <a href="../../../namespace/PhalconPlus.html">PhalconPlus</a>
        </span>
                <span class="namespace-piece">
            <a href="../../../namespace/PhalconPlus/Rpc.html">Rpc</a>
        </span>
        
        <h1 class="class-name">Yar</h1>
    </div>
    
</div>

<pre class="zephir-source-file prettyprint linenums">
    // <?php
namespace PhalconPlus\Rpc;
use Phalcon\DiInterface;

class Yar extends \Phalcon\Application
{
	protected serviceObj = null {
        get
    };
    protected requestArgs = "" {
        get
    };
    protected responseBody = "not supported http method" {
        get
    };

	public function __construct(<DiInterface> di = null)
	{
        parent::__construct(di);
		var rawBody = this->__get("request")->getRawBody();
		let this->requestArgs = msgpack_unpack(rawBody);
	}

	public function handle()// -> <\Phalcon\Http\Response>
	{
		if this->__get("request")->isGet() {
			let this->responseBody = "<h1>Welcome to Phalcon+</h1>
			<p>If you see this page, the msgpack-rpc server is successfully installed and
			working.</p>";
		} elseif this->__get("request")->isPost() {
            var e = null;
			var ret = [
				"errorCode" : 0,
				"errorMsg" : "",
				"logId" : this->__get("logger")->logId,
				"data" : []
			];
			try {
                if empty this->requestArgs {
                    throw new \Exception("invalid request args");
                }
				let this->serviceObj = this->getDi()->get("backendSrv");
				let ret["data"] = this->serviceObj->callByObject(this->requestArgs);
			} catch \Exception, e {
				let ret["errorCode"] = max(e->getCode(), 1);
				let ret["errorMsg"] = e->getMessage();
			}
			let this->responseBody = msgpack_pack(ret);
		}
		echo this->responseBody;
        // var response;
        // let response = new \Phalcon\Http\Response();
		// response->setStatusCode(200, "OK");
		// response->setContent(this->responseBody);
		// return response;
	}
}</pre>
                </div>
            </div>
        </div>
    </body>
</html>
